package com.sinosoft.perfect.system.license.bean;

import java.sql.SQLException;
import java.util.TimerTask;

import com.sinosoft.perfect.system.license.service.LicenseDataService;
import com.sinosoft.perfect.system.license.vo.License;

public class LicenseReloadBean extends TimerTask{

	private LicenseContainerBean licenseContainerBean;
	private LicenseDataService licenseDataService;
	
	public LicenseContainerBean getLicenseContainerBean() {
		return licenseContainerBean;
	}
	public void setLicenseContainerBean(LicenseContainerBean licenseContainerBean) {
		this.licenseContainerBean = licenseContainerBean;
	}
	public LicenseDataService getLicenseDataService() {
		return licenseDataService;
	}
	public void setLicenseDataService(LicenseDataService licenseDataService) {
		this.licenseDataService = licenseDataService;
	}
	
	
	
	@Override
	public void run() {
		try {
			License license = licenseDataService.initLicense();
			if(license == null){
				license = licenseDataService.initLicense(licenseContainerBean.generateNewMechineNumber());
			}
			licenseContainerBean.setLicense(license);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		System.out.println("=====进入更新license=====");
	}

}
